package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TbParams;
import com.ruoyi.system.service.ITbParamsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 参数表Controller
 * 
 * @author ruoyi
 * @date 2025-02-17
 */
@RestController
@RequestMapping("/system/params")
public class TbParamsController extends BaseController
{
    @Autowired
    private ITbParamsService tbParamsService;

    /**
     * 查询参数表列表
     */
    @PreAuthorize("@ss.hasPermi('system:params:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbParams tbParams)
    {
        startPage();
        List<TbParams> list = tbParamsService.selectTbParamsList(tbParams);
        return getDataTable(list);
    }

    /**
     * 导出参数表列表
     */
    @PreAuthorize("@ss.hasPermi('system:params:export')")
    @Log(title = "参数表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbParams tbParams)
    {
        List<TbParams> list = tbParamsService.selectTbParamsList(tbParams);
        ExcelUtil<TbParams> util = new ExcelUtil<TbParams>(TbParams.class);
        util.exportExcel(response, list, "参数表数据");
    }

    /**
     * 获取参数表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:params:query')")
    @GetMapping(value = "/{paramsId}")
    public AjaxResult getInfo(@PathVariable("paramsId") String paramsId)
    {
        return success(tbParamsService.selectTbParamsByParamsId(paramsId));
    }

    /**
     * 新增参数表
     */
    @PreAuthorize("@ss.hasPermi('system:params:add')")
    @Log(title = "参数表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbParams tbParams)
    {
        return toAjax(tbParamsService.insertTbParams(tbParams));
    }

    /**
     * 修改参数表
     */
    @PreAuthorize("@ss.hasPermi('system:params:edit')")
    @Log(title = "参数表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbParams tbParams)
    {
        return toAjax(tbParamsService.updateTbParams(tbParams));
    }

    /**
     * 删除参数表
     */
    @PreAuthorize("@ss.hasPermi('system:params:remove')")
    @Log(title = "参数表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{paramsIds}")
    public AjaxResult remove(@PathVariable String[] paramsIds)
    {
        return toAjax(tbParamsService.deleteTbParamsByParamsIds(paramsIds));
    }
}
